#!/bin/bash
#
#
#sed -i "s/CRAPBOX_USER/$USER/g" "crapbox.plit.0"
#CRAPBOX_PATH
#CRAPBOX_SYNC_BIN
# what's your ssh server?

# Install into $HOME/.crapbox
if [ -f "$HOME/.crapbox" ]
	echo "Seems like you've already installed Crapbox?"
	echo "Remove the current installation? [y/N] "
	read n

	if [ "$n" == "Y" -o "$n" == "y" ]
	then
		echo "Removing Crapbox..."
		rm -fr $HOME/.crapbox
	else
		echo "Cancelled :("
		exit 1
	fi
else
	mkdir -p $HOME/.crapbox/bin
fi

echo "The directory that will be used for syncing is [$HOME/Crapbox]: "
read n

if [ "$n" == "" ]
then
	n="$HOME/Crapbox"
else
	echo "Ok. Will set the sync directory to $n [Y/n]?"
	read n

	if [ "$n" == "n" -o "$n" == "N" ]
	then
		echo "Cancelled :("
		exit 1
	fi
fi

# Create the sync directory
# XXX: check if already exists first
mkdir "$n"

install -m 0700 sync_crapbox.sh "$HOME/.crapbox/bin"
gcc crapbox_watch.c -framework CoreServices -o crapbox_watch

# XXX: check is succeeded
install -m 0700 crapbox_watch "$HOME/.crapboxn/bin"
